ShowTable of Contents
Overview
Lotus Expeditor Client for Desktop uses Eclipse Activities (org.eclipse.ui.activities) to dynamically add an remove items from the user interface. Actions such as menu items or tool bar can be grouped together under a single activity ID. When the activity does not apply to the current state of the screen, the activity can be disabled thereby removing the actions from the user interface.
An Example
When composite applications are opened within Expeditor, you'll notice two file actions are added to the menu bar: Make Available Offline... and Membership. If you were to open another perspective that is not a composite application, these two items would be removed from the menu bar. The act of switching between a composite application perspective either enables or disables the activity that controls these two menu items.
Removing the Menu Items
To remove the menu items, code simply disables the activity that groups the two items.
String id = "com.ibm.rcp.http.composite.application.activity";
IWorkbenchActivitySupport s = PlatformUI.getWorkbench()
.getActivitySupport();
IActivityManager m = s.getActivityManager();
IActivity a = m.getActivity(id);
if (a != null) {
// remove the activity
Set enabled = new HashSet(m.getEnabledActivityIds());
enabled.remove(id);
s.setEnabledActivityIds(enabled);
}
The
getEnabledActivityIds function can be used to inspect the current list of activities enabled. It may provide a starting point to understand what actions are contributed under the activity and whether disabling the activity yields the desired customization.
Ensuring the Menu Items Remain Hidden
As with other wiki article samples, certain actions within Expeditor can re-add previously removed customization. Earlier in the article, it was mentioned that switching to a composite application perspective enables the activity and thus adds the menu items. To ensure the menu items remain hidden, a perspective listener can be used to always disable the activity when a perspective is used. The listener is created and added via Eclipse's IStartup extension point (org.eclipse.ui.startup).
public void earlyStartup() {// always disable the File menu options for
// Membership
// Make available offline Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.addPerspectiveListener(new PerspectiveAdapter() {
@Override
public void perspectiveActivated(
IWorkbenchPage page,
IPerspectiveDescriptor desc) {
disableCaiActivity();
}
@Override
public void perspectiveChanged(IWorkbenchPage arg0, IPerspectiveDescriptor arg1, String arg2) { }
});
}
});
}